/*
 * @Description: person的reducer
 * @Author: 姚泽毅
 * @Date: 2021-09-02 14:42:43
 * @LastEditTime: 2021-09-02 15:36:15
 */
import { ADD_PERSON } from "../constant";
const initState = [{ name: "tom", id: "001", age: 18 }];
export default function personReducer(preState = initState, action) {
	const { type, data } = action;

	switch (type) {
		case ADD_PERSON:
			// 必须返回一个新数组，redux底层使用了浅比较
			return [data, ...preState];
		default:
			return preState;
	}
}
